import 'package:courseapp/entity/StudentSignRecordDTO.dart' as StudentSignDTO;
import 'package:courseapp/http/HttpUtils.dart';
import 'package:flutter/material.dart';

class StudentSignRecord extends StatefulWidget {





  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return StudentSignState();
  }


}


class StudentSignState extends State {



  static int teacherSignId;
  List<StudentSignDTO.DataBean> _list = [];

  @override
  void initState()  {
     initRequest();
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(appBar: AppBar(leading: FlatButton(child:Icon(Icons.arrow_back,color: Colors.white,),onPressed: (){Navigator.of(context).pop();},),title: Text("学生签到情况"),),
     body: ListView.builder(
         itemCount: _list.length,
         itemBuilder: _buildItem),
    );
  }


  Widget _buildItem(BuildContext context, int index) {
    StudentSignDTO.DataBean dataBean = _list[index];
    String nickName = dataBean.nickName;
    String sign = dataBean.isSign? "签到":"未签到";
    Color txtColor = dataBean.isSign? Colors.black:Colors.red;
    return  FlatButton(
        color: Colors.white,
        padding: EdgeInsets.all(0),
        child: DecoratedBox(
            decoration: BoxDecoration( color: Colors.white, border: Border(bottom: Divider.createBorderSide(context, color: Colors.grey),)),
            child:Container(padding: EdgeInsets.all(5) ,child: Column(children: <Widget>[
              Container(alignment: Alignment.centerLeft, child:Text("学生姓名: $nickName",style: TextStyle(color: Colors.black),)),
              Container(alignment: Alignment.centerLeft, child:Text("签到状态: $sign",style: TextStyle(color: txtColor)), ),],)))
    );
  }

  void initRequest() async {
     StudentSignDTO.StudentSignRecordDTO signRecordDTO = await HttpUtil.getInstance().queryStudentSign(teacherSignId);
     _list.addAll(signRecordDTO.data);
     setState(() {});
  }


}
